package cn.edu.scau.cmi.xuchuangxiong.client;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import javafx.stage.Stage;

import java.awt.Image;
import java.awt.GridBagLayout;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JButton;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;

public class ComprehensiveExperiment extends JFrame {

	private JPanel contentPane;

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					ComprehensiveExperiment frame = new ComprehensiveExperiment();
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public ComprehensiveExperiment() {
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 527, 337);
		JLabel label = new JLabel();
		label.setBounds(24, 23, 153, 190);
		contentPane = new JPanel();
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(null);
		String imagePath = "image/personalPhoto.jpg";
		ImageIcon image = new ImageIcon(imagePath);
		Image img = image.getImage();
		img = img.getScaledInstance(label.getWidth(), label.getHeight(), Image.SCALE_DEFAULT);
		image.setImage(img);
		label.setIcon(image);
		contentPane.add(label);
		
		JLabel lblNewLabel = new JLabel("学号：   201727010220");
		lblNewLabel.setBounds(29, 231, 173, 15);
		contentPane.add(lblNewLabel);
		
		JLabel label_1 = new JLabel("姓名：   许创熊");
		label_1.setBounds(29, 256, 173, 15);
		contentPane.add(label_1);
		
		JButton btnNewButton = new JButton("实验1：单例模式");
		btnNewButton.setBounds(198, 23, 136, 23);
		contentPane.add(btnNewButton);
		btnNewButton.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				SingletonClient  slc = new SingletonClient();
				slc.setVisible(true);
			}
		});
		
		JButton button = new JButton("实验2：多例模式");
		button.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				MultipletonClient mlc = new MultipletonClient();
				mlc.setVisible(true);
			}
		});
		button.setBounds(198, 69, 136, 23);
		contentPane.add(button);
		
		JButton button_1 = new JButton("实验3：简单工厂");
		button_1.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				SimpleFactoryMethodClient sfmc = new SimpleFactoryMethodClient();
				JOptionPane.showMessageDialog(null, "请前往控制台查看结果","", JOptionPane.INFORMATION_MESSAGE);
				System.out.println("******实验3：简单工厂******");
				sfmc.main();
			}
		});
		button_1.setBounds(198, 115, 136, 23);
		contentPane.add(button_1);
		
		JButton button_2 = new JButton("实验3：工厂模式");
		button_2.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JOptionPane.showMessageDialog(null, "请前往控制台查看结果","", JOptionPane.INFORMATION_MESSAGE);
				
				System.out.println("******实验3：工厂模式******");
				FactoryClient fc = new FactoryClient();
				fc.main();
			}

		});
		button_2.setBounds(198, 158, 136, 23);
		contentPane.add(button_2);
		
		JButton button_3 = new JButton("实验3：抽象工厂");
		button_3.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent e) {
				JOptionPane.showMessageDialog(null, "请前往控制台查看结果","", JOptionPane.INFORMATION_MESSAGE);
				
				System.out.println("******实验3：抽象工厂******");
				AbstractFactoryClient fc = new AbstractFactoryClient();
				fc.main();
			}
		});
		button_3.setBounds(198, 204, 136, 23);
		contentPane.add(button_3);
		
		JButton button_4 = new JButton("实验4：类适配器");
		button_4.setBounds(355, 23, 136, 23);
		contentPane.add(button_4);
		
		JButton button_5 = new JButton("实验4：对象适配器");
		button_5.setBounds(355, 69, 136, 23);
		contentPane.add(button_5);
		
		JButton button_6 = new JButton("实验5：安全组合");
		button_6.setBounds(355, 115, 136, 23);
		contentPane.add(button_6);
		
		JButton button_7 = new JButton("实验5：一致性组合");
		button_7.setBounds(355, 158, 136, 23);
		contentPane.add(button_7);
		
		JButton button_8 = new JButton("实验6：Mybatis");
		button_8.setBounds(355, 204, 136, 23);
		contentPane.add(button_8);
		
		JButton button_9 = new JButton("实验7：Spring+Mbatis");
		button_9.setBounds(198, 252, 159, 23);
		contentPane.add(button_9);
		
	}
}
